Define function not showing errors but does not return anything when function is run